package cn.lizemin.builder.version0.entity;

/**
 * @author lzm
 * @version 1.0
 * @description: 工程总监
 * @date 2022/4/27 11:30
 */
public class Director {

    /**
     * 这里使用了接口，意味着扩展，变化，和多态，是系统中变化的那部分
     */
    private Builder builder;

    public Director(Builder builder) {
        this.builder = builder;
    }

    /**
     * set方法，允许修改
     * @param builder
     */
    public void setBuilder(Builder builder) {
        this.builder = builder;
    }

    /**
     * 负责房子的有序建造，最终完成交付，是系统中不变的那部分
     * @return
     */
    public Building direct() {
        builder.buildBasement();
        builder.buildWall();
        builder.buildProof();
        return builder.getBuilding();
    }

}
